﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.Core.Extensions
{
    /// <summary>
    /// Int 扩展类
    /// </summary>
    public static class IntExtensions
    {
        /// <summary>
        /// 执行 n 次循环
        /// </summary>
        /// <param name="count">循环次数</param>
        /// <param name="action">执行内容</param>
        public static void Times(this int count, Action action)
        {
            for (int i = 0; i < count; i++)
            {
                action();
            }
        }

        /// <summary>
        /// 执行 n 次循环
        /// </summary>
        /// <param name="count">循环次数</param>
        /// <param name="action">执行内容，带 Index </param>
        public static void Times(this int count, Action<int> action)
        {
            for (int i = 0; i < count; i++)
            {
                action(i);
            }
        }
    }
}
